<?php
require_once (APPLICATION_DIR."/application/model/Event.php");
class AlumniEvent
{
	function delEvent($p_intId)
	{
		$objEvent = new DataObjects_Event();
		$objEvent -> event_id = $p_intId;
		
		return $objEvent -> delete();
	}
	
	function updateEvent($p_arrInfo)
	{
                global  $arrArgs;
                $objEvent = new DataObjects_Event();
		$objEvent -> event_title = $p_arrInfo["eTitle"];
		$objEvent -> event_startdate = $p_arrInfo["eStartdate"];	
                $objEvent -> event_enddate = $p_arrInfo["eEnddate"];			
		$objEvent -> event_status = $p_arrInfo["status"];		
		$objEvent -> whereAdd("event_id=" . $arrArgs[1]);
		
		return $objEvent -> update(DB_DATAOBJECT_WHEREADD_ONLY);
	}
	function getInfoEvent($p_intId)
	{
		$objNews = new DataObjects_Event();
		$objNews -> selectAdd();
		$objNews -> selectAdd('*');
		$objNews -> whereAdd("event_id=" . $p_intId);
		$arrTmp = $objNews -> fetchList();
		
		if ( count($arrTmp) )
			return $arrTmp[0];
		else
			return false;
	}

	function addEvent($p_arrInfo)
	{                        
		$objEvent = new DataObjects_Event();
		$objEvent -> event_title = $p_arrInfo["eTitle"];
		$objEvent -> event_startdate = $p_arrInfo["eStartdate"];
		$objEvent -> event_enddate = $p_arrInfo["eEnddate"];
		//$objEvent -> event_image = $p_arrInfo["eImage"];
		//$objEvent -> event_content = $p_arrInfo["eContent"];
		$objEvent -> event_status = $p_arrInfo["status"];;
		$objEvent -> event_createddate = date("Y-m-d H:i:s");
		
		return $objEvent -> insert();
	}
	
	function getListEvent($p_intStart, $p_intLimit)
	{
		$objEvent = new DataObjects_Event();
		
		$objEvent -> limit($p_intStart, $p_intLimit);
		$objEvent -> find();
		return $objEvent;
	}
        function getUpcommingEvent(){
            $objEvent = new DataObjects_Event();
            $objEvent->selectAdd();
            $objEvent->selectAdd("event_id, DATE_FORMAT(event_startdate , '%d/%m/%Y') as startdate, event_title");
            $objEvent->whereAdd();
            $objEvent->whereAdd("event_startdate >= ".date('Y-m-d'));
            $objEvent->whereAdd("event_status = 1");
            $objEvent->orderBy();
            $objEvent->orderBy("event_startdate");
            $objEvent->find();
            return $objEvent->fetchList();
        }
}
?>